package com.linkoog.devtools.run_configuration;

import com.intellij.execution.configurations.RunConfigurationBase;
import com.intellij.openapi.options.ConfigurationException;
import com.intellij.openapi.options.SettingsEditor;
import com.intellij.openapi.util.Key;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

public class EnvFileRunConfigurationEditor<T extends RunConfigurationBase<?>> extends SettingsEditor<T> {
    private static final Key<EnvFileSettings> USER_DATA_KEY = new Key<>("EnvFile Settings");

    private static final String ELEMENT_ENTRY_LIST = "ENTRIES";
    private static final String ELEMENT_ENTRY_SINGLE = "ENTRY";

    private static final String FIELD_IS_ENABLED = "IS_ENABLED";
    private static final String FIELD_SUBSTITUTE_VARS = "IS_SUBST";
    private static final String FIELD_PATH_MACRO_VARS = "IS_PATH_MACRO_SUPPORTED";
    private static final String FIELD_IGNORE_MISSING = "IS_IGNORE_MISSING_FILES";
    private static final String FIELD_EXPERIMENTAL_INTEGRATIONS = "IS_ENABLE_EXPERIMENTAL_INTEGRATIONS";
    private static final String FIELD_PATH = "PATH";
    private static final String FIELD_PARSER = "PARSER";

    private static final String FIELD_IS_EXECUTABLE = "IS_EXECUTABLE";


    public EnvFileRunConfigurationEditor(T configuration) {
        //editor = new EnvFileConfigurationPanel<>(configuration);
    }

    @Override
    protected void resetEditorFrom(@NotNull T configuration) {
        EnvFileSettings state = configuration.getCopyableUserData(USER_DATA_KEY);
        if (state != null) {
            //editor.setState(state);
        }
    }

    @Override
    protected void applyEditorTo(@NotNull T configuration) throws ConfigurationException {
        //configuration.putCopyableUserData(USER_DATA_KEY, );
    }

    public static EnvFileSettings getEnvFileSetting(@NotNull RunConfigurationBase<?> runConfigurationBase) {
        return runConfigurationBase.getCopyableUserData(USER_DATA_KEY);
    }

    @NotNull
    @Override
    protected JComponent createEditor() {
        return new JPanel();
    }
}
